package com.xiaohei.rabbitmq.eight;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import com.xiaohei.rabbitmq.utils.RabbitmqUtils;

import java.nio.charset.StandardCharsets;

/**
 * 死信队列
 * 消费者1
 * @author 王希辰
 * @since 2022/3/18 13:29
 */
public class Consumer02 {
    //死信队列
    public static final String DEAD_QUEUE="dead_queue";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitmqUtils.getChannel();
        System.out.println("Consumer02等待接收消息");
        DeliverCallback deliverCallback=(consumerTag,message)->{
            System.out.println("Consumer02接收消息："+new String(message.getBody(),StandardCharsets.UTF_8));
        };


        channel.basicConsume(DEAD_QUEUE,true, deliverCallback,consumerTag -> {});
    }

}
